package com.bosssoft.controller;

import com.bosssoft.entity.po.FibVoucherDetailsPO;
import com.bosssoft.excelEntity.VO.*;
import com.bosssoft.exception.DaoException;
import com.bosssoft.fegin.OssFeginService;
import com.bosssoft.response.Result;
import com.bosssoft.service.FibCreateVoucherService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

/**
 * @author Aria
 */
@Api(tags = "凭证生成")
@RestController
@RequestMapping("/creatVoucherDetails")
public class FibGetVoucherController {

    @Autowired
    OssFeginService ossFeginService;

    @Autowired
    FibCreateVoucherService createVoucherService;

    @ApiOperation(value = "22031生成直接支付退款通知书")
    @PostMapping("/addPayRefundNoticeDirectly")
    public Result addPayRefundNoticeDirectly(@RequestBody PayRefundNoticeDirectlyVO addPayRefundNoticeDirectlyVO) throws Exception {
        MultipartFile multipartFile = null;
        System.out.println(addPayRefundNoticeDirectlyVO);
        try {
            System.out.println(addPayRefundNoticeDirectlyVO);
            FibVoucherDetailsPO payRefundNoticeDirectly = createVoucherService.createAddPayRefundNoticeDirectly(addPayRefundNoticeDirectlyVO);
            //返回数据库记录
            return Result.ok().data("data", payRefundNoticeDirectly);
        } catch (DaoException e) {
            return Result.error(e.getCode(), e.getMessage());
        }
    }

    @ApiOperation(value = "52011生成财政直接支付凭证")
    @PostMapping("/addDirectPfinancialPayment")
    public Result addDirectPfinancialPayment(@RequestBody DirectPfinancialPaymentVO directPfinancialPaymentVO) throws Exception {
        MultipartFile multipartFile = null;
        try {
            FibVoucherDetailsPO directPfinancialPayment = createVoucherService.createDirectPfinancialPayment(directPfinancialPaymentVO);
            //返回数据库记录
            System.out.println(directPfinancialPayment);
            return Result.ok().data("data", directPfinancialPayment);
        } catch (DaoException e) {
            System.out.println("error");
            return Result.error(e.getCode(), e.getMessage());
        }
    }

    @ApiOperation(value = "22050直接支付入账通知书")
    @PostMapping("/addFinancialDirectPaymentEntryNotice")
    public Result addFinancialDirectPaymentEntryNotice(@RequestBody FinancialDirectPaymentEntryNoticeVO financialDirectPaymentEntryNoticeVO) throws Exception {
        MultipartFile multipartFile = null;
        try {
            FibVoucherDetailsPO directPfinancialPayment = createVoucherService.createFinancialDirectPaymentEntryNotice(financialDirectPaymentEntryNoticeVO);
            //返回数据库记录
            return Result.ok().data("data", directPfinancialPayment);
        } catch (DaoException e) {
            return Result.error(e.getCode(), e.getMessage());
        }
    }

    @ApiOperation(value = "50180直接支付汇总清算额度通知单（清算依据）")
    @PostMapping("/addDirectPaymentSummaryClearingLineNoticeGist")
    public Result addDirectPaymentSummaryClearingLineNoticeGist(@RequestBody DirectPaymentSummaryClearingLineNoticeGistVO directPaymentSummaryClearingLineNoticeGistVO) throws Exception {
        MultipartFile multipartFile = null;
        try {
            FibVoucherDetailsPO directPfinancialPayment = createVoucherService.createDirectPaymentSummaryClearingLineNoticeGist(directPaymentSummaryClearingLineNoticeGistVO);
            //返回数据库记录
            return Result.ok().data("data", directPfinancialPayment);
        } catch (DaoException e) {
            return Result.error(e.getCode(), e.getMessage());
        }
    }

    @ApiOperation(value = "50181直接支付汇总清算额度通知单(退财政回单)")
    @PostMapping("/addDirectPaymentSummaryClearingLineNotice")
    public Result addDirectPaymentSummaryClearingLineNotice(@RequestBody DirectPaymentSummaryClearingLineNoticeVO directPaymentSummaryClearingLineNoticeGistVO) throws Exception {
        MultipartFile multipartFile = null;
        try {
            FibVoucherDetailsPO directPfinancialPayment = createVoucherService.createDirectPaymentSummaryClearingLineNotice(directPaymentSummaryClearingLineNoticeGistVO);
            //返回数据库记录
            return Result.ok().data("data", directPfinancialPayment);
        } catch (DaoException e) {
            return Result.error(e.getCode(), e.getMessage());
        }
    }

    @ApiOperation(value = "52070预算拨款凭证")
    @PostMapping("/addVoucherBudgetAllocatio")
    public Result addVoucherBudgetAllocatio(@RequestBody VoucherBudgetAllocationVO voucherBudgetAllocationVO) throws Exception {
        MultipartFile multipartFile = null;
        try {
            FibVoucherDetailsPO directPfinancialPayment = createVoucherService.createVoucherBudgetAllocation(voucherBudgetAllocationVO);
            //返回数据库记录z
            return Result.ok().data("data", directPfinancialPayment);
        } catch (DaoException e) {
            return Result.error(e.getCode(), e.getMessage());
        }
    }
    @ApiOperation(value = "52071预算拨款凭证 回单")
    @PostMapping("/addVoucherBudgetAllocationReceipt")
    public Result addVoucherBudgetAllocationReceipt(@RequestBody VoucherBudgetAllocationReceiptVO voucherBudgetAllocationReceiptVO) throws Exception {
        MultipartFile multipartFile = null;
        try {
            FibVoucherDetailsPO directPfinancialPayment = createVoucherService.createVoucherBudgetAllocationReceipt(voucherBudgetAllocationReceiptVO);
            //返回数据库记录
            return Result.ok().data("data", directPfinancialPayment);
        } catch (DaoException e) {
            return Result.error(e.getCode(), e.getMessage());
        }
    }
}
